<template>
	<view class="container">
		<view class="display-type margin-b-xs">
			<view @click="uploadLogoFn(1)" class="flex-wrp flex-jun" style="height: 160rpx;border-bottom: 2rpx solid #F8F8F8;">
				<view class="titet">电工证：</view>
				<view class="flex-wrp flex-j-c" style="gap: 20rpx;">
					<view class="iconBox flex-wrp">
						<image v-if="!logo" class="logoPic" :src="imgHead+'card/photo/20250516/1747384150501.png'"></image>
						<image v-if="logo" class="logoPic" :src="logo" mode="aspectFill"></image>
					</view>
					<view class="arrowR">
						<image :src="imgHead+'card/photo/20250529/1748500127333.png'"></image>
					</view>
				</view>
			</view>
			<view @click="uploadLogoFn(2)" class="flex-wrp flex-jun" style="height: 160rpx;border-bottom: 2rpx solid #F8F8F8;">
				<view class="titet">商保证明：</view>
				<view class="flex-wrp flex-j-c" style="gap: 20rpx;">
					<view class="iconBox flex-wrp">
						<image v-if="!logo1" class="logoPic" :src="imgHead+'card/photo/20250516/1747384150501.png'"></image>
						<image v-if="logo1" class="logoPic" :src="logo1" mode="aspectFill"></image>
					</view>
					<view class="arrowR">
						<image :src="imgHead+'card/photo/20250529/1748500127333.png'"></image>
					</view>
				</view>
			</view>
		</view>
		<view style="color: orangered;" v-if="userInfo.authenticationStatus==2">驳回理由：{{userInfo.refusal?userInfo.refusal:'无'}}</view>
		<view class="card-btn">
			<view class="add-card" v-if="userInfo.authenticationStatus!=2&&userInfo.electricianCertificate">认证中,请等待管理员审核</view>
			<view class="add-card" v-else-if="userInfo.authenticationStatus==2" @click="sureMessageFn">重新认证</view>
			<view class="add-card" v-else @click="sureMessageFn">确定</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				imgHead: 'https://qr-card.oss-accelerate.aliyuncs.com/',
				logo:'',
				logo1:'',
				name:'',
				detail:'',
				location: {
					name:'',
					address:'',
					latitude: '', // 纬度
					longitude: '', // 经度
				},
				imageList:[],
				userInfo:{},
				id:'',
			}
		},
		onLoad(e) {
			this.userInfo = uni.getStorageSync('userInfo')
			if(this.userInfo.electricianCertificate&&this.userInfo.electricianCertificate!='null'){
				this.logo = this.userInfo.electricianCertificate
			}
			if(this.userInfo.merchantGuarantees&&this.userInfo.merchantGuarantees!='null'){
				this.logo1 = this.userInfo.merchantGuarantees
			}
		},
		methods: {
			uploadLogoFn(e){
				uni.chooseImage({
					count: 1,
					success: async (res) => {
						uni.uploadFile({
							url: this.$baseUrl + '/api/userUpload',
							filePath: res.tempFilePaths[0],
							header:{ Authorization : 'Bearer '+uni.getStorageSync('token')},
							name: 'file',
							success: (res1)=> {
								if(e == 1){
									this.logo = JSON.parse(res1.data).result
								}else {
									this.logo1 = JSON.parse(res1.data).result
								}
							}
						});
					}
				});
			},
			sureMessageFn(){
				if(!this.logo){
					uni.showToast({
						title:'请上传电工证',
						icon:'none'
					})
					return
				}
				if(!this.logo1){
					uni.showToast({
						title:'请上传商保证明',
						icon:'none'
					})
					return
				}
				this.$http('/api/user/certifiedElectrician',{
					electricianCertificate:this.logo,
					merchantGuarantees: this.logo1
				},'POST',1).then(res=>{
					if(res.code == 200){
						uni.navigateBack().then(res=>{
							uni.showToast({
								title:'认证成功，请等待管理员审核',
								icon:'none'
							})
						})
					}else {
						uni.showToast({
							title:res.message,
							icon:'none'
						})
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		background-color: #F9F9F9;
		min-height: 100vh;
		padding: 20rpx 24rpx;
	}
	image {
		width: 100%;
		height: 100%;
	}
	.display-type{
		padding: 0 30rpx;
		height: 320rpx;
		background: #FFFFFF;
		border-radius: 20rpx 20rpx 20rpx 20rpx;
		.titet{
			font-weight: 400;
			font-size: 32rpx;
			color: #333333;
			line-height: 32rpx;
			height: 32rpx;
		}
		.icon-box{
			height: 32rpx;
			.txt{
				font-weight: 400;
				font-size: 28rpx;
				color: #333333;
				line-height: 28rpx;
			}
		}
		.arrowR{
			width: 10rpx;
			height: 20rpx;
			display: flex;
			image{
				width: 100%;
				height: 100%;
			}
		}
		.display-type-icon{
			width: 10rpx;
			height: 20rpx;
			margin-left: 20rpx;
		}
		.inputBox{
			width: 260rpx;
			height: 28rpx;
			font-weight: 400;
			font-size: 28rpx;
			color: #ABAAAF;
			line-height: 28rpx;
			text-align: right;
		}
		.iconBox{
			width: 108rpx;
			height: 108rpx;
			image{
				width: 100%;
				height: 100%;
			}
		}
		.input1 {
			color: #333333;
			font-size: 28rpx;
			width: 100%;
		}
		.color-list{
			.color-item{
				border: 2rpx solid transparent;
				border-radius: 14rpx 14rpx 14rpx 14rpx;
				padding: 6rpx;
				margin-left: 48rpx;
				view{
					width: 48rpx;
					height: 48rpx;
					border-radius: 10rpx 10rpx 10rpx 10rpx;
				}
				.color1{
					background: #FF6060;
				}
				.color2{
					background: #337BE6;
				}
				.color3{
					background: #35CC2D;
				}
			}
			.active{
				border: 2rpx solid #005CFF;
			}
		}
	}
	.card-btn{
		width: 100%;
		background: #FFFFFF;
		padding: 20rpx 20rpx 60rpx;
		
		position: fixed;
		bottom: 0;
		left: 0;
		z-index: 99;
		.add-card{
			height: 94rpx;
			background: #005CFF;
			border-radius: 16rpx 16rpx 16rpx 16rpx;
			font-family: Source Han Sans CN, Source Han Sans CN;
			font-weight: bold;
			font-size: 32rpx;
			color: #FFFFFF;
			text-align: center;
			line-height: 94rpx;
			z-index: 99;
		}
	}
	.positioning{
		height: 128rpx;
		padding: 0 24rpx;
		.text{
			width: 532rpx;
			height: 72rpx;
			font-family: Source Han Sans CN, Source Han Sans CN;
			.txt11{
				font-weight: 500;
				font-size: 28rpx;
				color: #333333;
				line-height: 28rpx;
				height: 28rpx;
			}
			.txt22{
				font-weight: 400;
				font-size: 24rpx;
				color: #777777;
				line-height: 24rpx;
				height: 24rpx;
			}
		}
	}
	
	.temporarilyImg {
		padding-top: 100rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		image {
			width: 246rpx;
			height: 176rpx;
		}
	}
	
	.space-alliance{
		.add-alliance{
			margin: 20rpx 0;
			background: #FFFFFF;
			border-radius: 20rpx;
			padding: 42rpx 0;
			
			display: flex;
			justify-content: center;
			align-items: center;
			gap: 20rpx;
			.add-alliance-icon{
				width: 32rpx;
				height: 32rpx;
				image{
					height: 100%;
					width: 100%;
				}
			}
			.add-alliance-txt{
				font-weight: 500;
				font-size: 32rpx;
				color: #3A87FF;
				line-height: 32rpx;
			}
		}
		
	}
	.space-alliance-list{
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 40rpx 30rpx;
		background: #FFFFFF;
		border-radius: 20rpx;
		.space-alliance-list-info{
			display: flex;
			justify-content: center;
			align-items: center;
			gap: 20rpx;
			.space-alliance-list-icon{
				width: 108rpx;
				height: 108rpx;
				border-radius: 100%;
				image{
					width: 100%;
					height: 100%;
					border-radius: 100%;
				}
			}
			.space-alliance-list-main{
				max-width: 372rpx;
				height: 100rpx;
				
				display: flex;
				justify-content: center;
				align-items: center;
				flex-direction: column;
				align-items: flex-start;
				gap: 20rpx;
				.space-alliance-list-main-title{
					font-weight: bold;
					font-size: 32rpx;
					color: #333333;
					height: 48rpx;
					line-height: 48rpx;
					
					max-width: 372rpx;
					display: -webkit-box;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 1;
					overflow: hidden;
					text-overflow: ellipsis;
				}
				.space-alliance-list-main-bottom{
					display: flex;
					justify-content: center;
					align-items: center;
					gap: 16rpx;
					.bottom-area-box{
						display: flex;
						justify-content: center;
						align-items: center;
						
						padding: 4rpx 10rpx;
						height: 32rpx;
						background: #F3F4F8;
						border-radius: 6rpx;
						
						font-weight: 400;
						font-size: 24rpx;
						color: #5C6375;
						line-height: 24rpx;
					}
					.bottom-city-box{
						display: flex;
						justify-content: center;
						align-items: center;
						
						padding: 4rpx 10rpx;
						height: 32rpx;
						background: #E3F3FF;
						border-radius: 6rpx;
						
						font-weight: 400;
						font-size: 24rpx;
						color: #4185FF;
						line-height: 24rpx;
					}
				}
			}
		}
		.space-alliance-list-handle{
			width: 112rpx;
			height: 60rpx;
			border-radius: 44rpx;
			border: 2rpx solid #E6E6E6;
			color: #333333;
			
			display: flex;
			justify-content: center;
			align-items: center;
		}
	}
	.margin-b-xs{
		margin-bottom: 20rpx;
	}
	.lengthTxt {
		position: absolute;
		top: 26rpx;
		right: 30rpx;
		font-size: 28rpx;
		color: #AAAAAA;
	}
	
	.imgBox {
		width: 100%;
		height: 100%;
		display: flex;
		flex-wrap: wrap;
		.picBox {
			width: 200rpx;
			height: 200rpx;
			margin: 0 16rpx 16rpx 0;
			position: relative;
			&:nth-child(3n){
				margin: 0 0;
			}
			.deletePic {
				position: absolute;
				width: 40rpx;
				height: 40rpx;
				top: -10rpx;
				right: -10rpx;
			}
		}
		.addPic {
			width: 200rpx;
			height: 200rpx;
		}
	}
</style>
